<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
namespace Api\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
use Core\Entity;
use Core\Service;
use Doctrine\ORM\EntityManager;

class CategoriesController extends AbstractActionController {

    public function indexAction() {
        return new JsonModel(array('data' => "Welcome to the Zend Framework Album API example"));
    }
    
    public function getAllAction() {
        $categoriesService= new \Core\Service\CategoriesService();
        $em = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
        $results= $em->createQuery('select u from Core\Entity\User u')->getArrayResult();

       
        return new JsonModel(array(
            'data' => $categoriesService->findAll($em))
        );
    }
    

    

}
